from cmath import log
from pydoc import describe
from fastapi import APIRouter, Request
import requests
import json

gaodeRouter = APIRouter(prefix="/gaode", tags=['高德'])

'逆地理信息查询'


@gaodeRouter.get("/GaodeGeocode", summary="高德地理信息编码")
async def get_geocode(request: Request,  address: str = "北京市朝阳区阜通东大街6号"):

    addressList = address.replace(',', "|")
    print(addressList)
    params = {
        "key": '918b050ab07d69cf54abf79c9054afb0',
        "address": addressList,
        "batch": True
    }
    results = requests.get(url='https://restapi.amap.com/v3/geocode/geo',
                           params=params, headers=request.headers, verify=True)
    return {
        "content": json.loads(results.content)
    }
